﻿using System;
using FileManager_Server.BusinessLogic.IRepository_Service;
using FileManager_Server.BusinessLogic.Respository_Service;
using FileManager_Server.BusinessLogic.WCF.System_Setting_Service;
using FileManager_Server.Utility;
using FileManager_Server.Utility.ObjectContainers.Unity;

namespace FileManager_Server.BusinessLogic.WCF.ObjectContainer_Setting
{
    public sealed class ObjectContainerInstance
    {
        private static readonly ObjectContainerInstance ObjectContainer_Instance = new ObjectContainerInstance();

        static ObjectContainerInstance()
        {
            try
            {
            }
            catch (Exception ex)
            {
                LogLoader.Instance.Log.Info("Initialize ObjectContainerInstance has problem:", ex);
            }
        }
        ObjectContainerInstance()
        {
            try
            {
                UnityObject_Container = new UnityObjectContainer();
                UnityObject_Container.Initialize();
                UnityObject_Container.RegisterType<ISystemService, SystemService>();
                UnityObject_Container.RegisterType<IUserService, UserService>();
                UnityObject_Container.RegisterType<IFileService, FileService>();
            }
            catch (Exception ex)
            {
                LogLoader.Instance.Log.Info("Create UnityObjectContainer has problem:", ex);
            }
        }

        public static ObjectContainerInstance Instance
        {
            get { return ObjectContainer_Instance; }
        }

        public UnityObjectContainer UnityObject_Container { get; private set; }
    }
}